//
//  RBCompeCalendarCollecCell.m
//  RMMaterialRed
//
//  Created by XBWH on 2024/3/12.
//

#import "RBCompeCalendarCollecCell.h"
#import "RBCompeCalendarModel.h"

@interface RBCompeCalendarCollecCell ()
@property(strong,nonatomic)UIView *bgView;
@property(strong,nonatomic)UILabel *weekLabel;
@property(strong,nonatomic)UILabel *dateLabel;
@property(strong,nonatomic)UIImageView *lineImageView;
@end

@implementation RBCompeCalendarCollecCell

- (instancetype)initWithFrame:(CGRect)frame{
    
    if(self = [super initWithFrame:frame]){
        
        self.backgroundColor = [UIColor clearColor];
        self.contentView.backgroundColor = [UIColor clearColor];
        [self rb_initViewUI];
        [self layoutIfNeeded];
    }
    return self;
}
-(void)rb_initViewUI{
    [self.contentView addSubview:self.bgView];
    [self.bgView addSubview:self.weekLabel];
    [self.bgView addSubview:self.dateLabel];
    [self.bgView addSubview:self.lineImageView];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.bottom.right.mas_equalTo(0);
    }];
    [self.weekLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(RBScaleWidth(7));
        make.height.mas_equalTo(RBScaleWidth(14));
        make.centerX.mas_equalTo(0);
    }];
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.weekLabel.mas_bottom).mas_offset(RBScaleWidth(6));
        make.height.mas_equalTo(RBScaleWidth(10));
        make.centerX.mas_equalTo(0);
    }];
    [self.lineImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.centerX.mas_equalTo(0);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(2);
    }];
}
-(void)setModel:(RBCompeCalendarModel *)model{
    _model=model;
    self.weekLabel.text = model.weekTime;
    self.dateLabel.text = model.dateTime.rb_newFormatMMdd;
    if (model.isSelectDate) {
        self.weekLabel.textColor = RBColor(242, 48, 48);
        self.dateLabel.textColor = RBColor(242, 48, 48);
        self.lineImageView.hidden = NO;
    } else {
        self.weekLabel.textColor = RBColor(51, 51, 51);
        self.dateLabel.textColor = RBColor(153, 153, 153);
        self.lineImageView.hidden = YES;
    }
}
- (UIView *)bgView{
    if(_bgView==nil){
        _bgView = [[UIView alloc] init];
    }
    return _bgView;
}
-(UILabel *)weekLabel{
    if(_weekLabel==nil){
        _weekLabel = [UILabel rb_labelWithTitle:@"今天" color:RBColor(255, 0, 0) font:RBPingFangMediumFont(15) alignment:NSTextAlignmentCenter];
    }
    return _weekLabel;
}
-(UILabel *)dateLabel{
    if(_dateLabel==nil){
        _dateLabel = [UILabel rb_labelWithTitle:@"03.12" color:RBColor(255, 0, 0) font:RBPingFangFont(12) alignment:NSTextAlignmentCenter];
    }
    return _dateLabel;
}
- (UIImageView *)lineImageView{
    if(_lineImageView==nil){
        _lineImageView = [[UIImageView alloc] init];
        _lineImageView.image = [UIImage imageNamed:@"rlhk"];
        _lineImageView.contentMode = UIViewContentModeScaleAspectFill;
        _lineImageView.hidden = YES;
    }
    return _lineImageView;
}

@end
